package top.dark.spring.config;

import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * Author: Darkn
 * description:
 * Create Time: 2021/5/4 22:12
 */
@Component
public class TopicListener implements MessageListener {
    @Override
    public void onMessage(Message message) {
        try {
            // Topic主题消费者监听消息
            String text = ((TextMessage) message).getText();
            System.out.println(this.getClass().getSimpleName() + "接受到消息---->" + text);
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}
